﻿using System;
using System.Collections.Generic;

namespace Dapper.Core
{
    /// <summary>
    /// 分页列表
    /// </summary>
    public class PageResult<T>
    {
        public PageResult()
        {

        }

        public PageResult(PageParam pagerInfo, List<T> items)
        {
            PageIndex = pagerInfo.PageIndex;
            PageSize = pagerInfo.PageSize;
            TotalItems = pagerInfo.RecordCount;
            PageTotal = (int)Math.Ceiling(pagerInfo.RecordCount / (double)pagerInfo.PageSize);
            Items = items;
        }
      
        /// <summary>
        /// 当前页码
        /// </summary>
        public int PageIndex { get; set; }

        /// <summary>
        /// 每页记录数
        /// </summary>
        public int PageSize { get; set; }

        /// <summary>
        /// 总记录数
        /// </summary>
        public int TotalItems { get; set; }

        /// <summary>
        /// 总页数
        /// </summary>
        public int PageTotal { get; set; }

        /// <summary>
        /// 分页数据
        /// </summary>
        public List<T> Items { get; set; }
    }
}
